package com.aaa.controller.sys;

import com.aaa.pojo.MyReturn;
import com.aaa.utils.Constants;
import com.aaa.utils.RetStatusEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;


@ControllerAdvice
public class BaseController {

    public MyReturn getSuccessResult(MyReturn myReturn) {
        if(null==myReturn){
            myReturn= new MyReturn();
        }
        myReturn.setCode(RetStatusEnum.SUCCESS.getCode());
        myReturn.setMsg(RetStatusEnum.SUCCESS.getMessage());
        return myReturn;
    }


    public  MyReturn getFailResult(MyReturn myReturn) {
        if(null==myReturn){
            myReturn= new MyReturn();
        }
        myReturn.setCode(RetStatusEnum.FAILE.getCode());
        myReturn.setMsg(RetStatusEnum.FAILE.getMessage());
        return myReturn;
    }
    public  MyReturn getLoginFailResult(MyReturn myReturn) {
        if(null==myReturn){
            myReturn= new MyReturn();
        }
        myReturn.setCode(RetStatusEnum.FAILE.getCode());
        myReturn.setMsg(Constants.ERROR_LOGIN);
        return myReturn;
    }

  /*  @ExceptionHandler( Exception.class)
    public ModelAndView toErrorPage(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("500");
        return mv;
    }
    @ExceptionHandler( Exception.class)
    @ResponseBody
    public MyReturn retureErrorInfo(){
        return this.getFailResult(null);
    }*/
}
